package com.dc.system.controller;

import com.dc.common.model.BaseModel;
import com.dc.system.model.SysDept;
import com.dc.system.model.SysOrgan;
import com.dc.system.service.SysOrganService;
import com.github.pagehelper.PageInfo;
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.wordnik.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: SysOrganController
 * @Author: ChenXueLi
 * @Date: 2018-05-05 10:39
 */
@Controller
@RequestMapping("/system/organ")
public class SysOrganController {

    @Autowired
    private SysOrganService sysOrganService;

    @ApiOperation(value = "添加单位", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "单位名称", required = true, paramType = "query"),
            @ApiImplicitParam(name = "fk_parent_id", value = "上级部门id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "contact", value = "联系人", required = true, paramType = "query"),
            @ApiImplicitParam(name = "contact_phone", value = "联系人电话", required = true, paramType = "query"),
            @ApiImplicitParam(name = "staff_num", value = "员工数量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "address", value = "地址", required = true, paramType = "query"),
            @ApiImplicitParam(name = "nature", value = "单位性质", required = true, paramType = "query"),
            @ApiImplicitParam(name = "telephone", value = "座机", required = true, paramType = "query"),
            @ApiImplicitParam(name = "fax", value = "传真", required = false, paramType = "query"),
            @ApiImplicitParam(name = "memo", value = "备注", required = true, paramType = "query"),
            @ApiImplicitParam(name = "order_code", value = "排序", required = false, paramType = "query")
    })
    @RequestMapping("/addSysOrgan")
    @ResponseBody
    public BaseModel addSysOrgan(SysOrgan sysOrgan, BaseModel baseModel, HttpServletRequest request) throws Exception{
        return sysOrganService.addSysOrgan(sysOrgan, baseModel, request);
    }

    @ApiOperation(value = "根据id删除单位", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "organ_id", value = "单位id", required = true, paramType = "query")
    })
    @RequestMapping("/deleteSysOrganById")
    @ResponseBody
    public BaseModel deleteSysOrganById(SysOrgan sysOrgan, BaseModel baseModel, HttpServletRequest request) throws Exception{
        return sysOrganService.deleteSysOrganById(sysOrgan, baseModel, request);
    }

    @ApiOperation(value = "修改单位", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "organ_id", value = "单位id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "name", value = "单位名称", required = true, paramType = "query"),
            @ApiImplicitParam(name = "fk_parent_id", value = "上级单位id", required = true, paramType = "query"),
            @ApiImplicitParam(name = "contact", value = "联系人", required = true, paramType = "query"),
            @ApiImplicitParam(name = "contact_phone", value = "联系人电话", required = true, paramType = "query"),
            @ApiImplicitParam(name = "staff_num", value = "员工数量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "address", value = "地址", required = true, paramType = "query"),
            @ApiImplicitParam(name = "nature", value = "单位性质", required = true, paramType = "query"),
            @ApiImplicitParam(name = "telephone", value = "座机", required = true, paramType = "query"),
            @ApiImplicitParam(name = "fax", value = "传真", required = false, paramType = "query"),
            @ApiImplicitParam(name = "memo", value = "备注", required = true, paramType = "query"),
            @ApiImplicitParam(name = "order_code", value = "排序", required = false, paramType = "query")
    })
    @RequestMapping("/updateSysOrganById")
    @ResponseBody
    public BaseModel updateSysOrganById(SysOrgan sysOrgan, BaseModel baseModel, HttpServletRequest request) throws Exception{
        return sysOrganService.updateSysOrganById(sysOrgan, baseModel, request);
    }

    @ApiOperation(value = "分页查询单位", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前查询页数", required = false, paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "name", value = "单位名称", required = false, paramType = "query"),
            @ApiImplicitParam(name = "fk_parent_id", value = "上级单位id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "contact", value = "联系人", required = false, paramType = "query"),
            @ApiImplicitParam(name = "contact_phone", value = "联系人电话", required = false, paramType = "query"),
            @ApiImplicitParam(name = "staff_num", value = "员工数量", required = false, paramType = "query"),
            @ApiImplicitParam(name = "address", value = "地址", required = false, paramType = "query"),
            @ApiImplicitParam(name = "nature", value = "单位性质", required = false, paramType = "query"),
            @ApiImplicitParam(name = "telephone", value = "座机", required = false, paramType = "query"),
            @ApiImplicitParam(name = "fax", value = "传真", required = false, paramType = "query"),
            @ApiImplicitParam(name = "memo", value = "备注", required = false, paramType = "query"),
            @ApiImplicitParam(name = "order_code", value = "排序", required = false, paramType = "query"),
            @ApiImplicitParam(name = "create_user_id", value = "创建用户id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "create_user_name", value = "创建用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "create_time_start", value = "创建时间开始标记", required = false, paramType = "query"),
            @ApiImplicitParam(name = "create_time_end", value = "创建时间结束标记", required = false, paramType = "query"),
            @ApiImplicitParam(name = "update_user_id", value = "更新用户id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "update_user_name", value = "更新用户名", required = false, paramType = "query"),
            @ApiImplicitParam(name = "update_time_start", value = "更新时间开始标记", required = false, paramType = "query"),
            @ApiImplicitParam(name = "update_time_end", value = "更新时间结束标记", required = false, paramType = "query"),
            @ApiImplicitParam(name = "dept_id", value = "部门id", required = false, paramType = "query"),
            @ApiImplicitParam(name = "getByPage", value = "是否需要分页查询（只要有值就不是分页查询）", required = false, paramType = "query")
    })
    @RequestMapping("/getSysOrgans")
    @ResponseBody
    public BaseModel getSysOrgans(PageInfo<?> pageInfo, SysOrgan sysOrgan, SysDept sysDept, BaseModel baseModel, HttpServletRequest request) throws Exception {
        return sysOrganService.getSysOrgans(pageInfo, sysOrgan, sysDept, baseModel, request);
    }


}
